package cn.me.state;

/**
 * @author jia
 * @date 2021/2/21
 */

/**
 * 测试守护线程
 */
public class TestDaemon {
}


//上帝
class God implements Runnable {

    public static void main(String[] args) {
        God god = new God();
        You you = new You();
        Thread thread = new Thread(god);
        thread.setDaemon(true);//默认是false表示是守护线程，正常的线程都是用户线程
        thread.start();
        new Thread(you).start();//用户线程
    }

    @Override
    public void run() {
        while (true) {
            System.out.println("守护");
        }
    }
}

//你
class You implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 10000; i++) {
            System.out.println("过了" + i);
        }
        System.out.println("===bye===");
    }
}